package com.zonski.jbots.desktop.client.tile;

import java.awt.*;

import com.zonski.jbots.desktop.client.TileRenderer;

public class IndexedTileRenderer implements TileRenderer
{
    private Image[] images;
    private Component component;

    public IndexedTileRenderer(Image[] images, Component component)
    {
        this.images = images;
        this.component = component;
    }

    public void render(Graphics g, int tile, int x, int y, int width, int height)
    {
        Image image = getImage(tile);
        g.drawImage(image, x, y, width, height, this.component);
    }

    public Image getImage(int tile)
    {
        Image image;
        if(tile >= 0 && tile < this.images.length)
        {
            image = this.images[tile];
        }else{
            image = null;
        }
        return image;
    }
}
